package com.kuanter.kuanterauto.adapter;

import java.util.List;

import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.kuanter.kuanterauto.R;
import com.kuanter.kuanterauto.entity.CityArea;

public class CityAreaAdapter extends BaseAdapter {
	LayoutInflater factory;
	public static int selected_area = 0;
	private List<CityArea> cityAreaList;
	
	public CityAreaAdapter(LayoutInflater factory) {
		this.factory = factory;
	}

	@Override
	public int getCount() {
		int size = 0;
		if(cityAreaList != null) {
			size = cityAreaList.size();
		}
		return size;
	}

	@Override
	public Object getItem(int position) {
		return cityAreaList.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View conview, ViewGroup parent) {
		if(conview == null) {
			conview = factory.inflate(R.layout.list_servicetype_item, null);
		}
		TextView service_type = (TextView) conview.findViewById(R.id.service_type);
		service_type.setText(cityAreaList.get(position).getCityarea());
		if(position == selected_area) {
			/*conview.setBackgroundResource(R.color.pop_condicition_type_selected);
			service_type.setTextColor(Color.WHITE);*/
			conview.setBackgroundResource(R.color.pop_condicition_type_selected);
			service_type.setTextColor(Color.WHITE);
		} else {
			conview.setBackgroundResource(R.drawable.list_site_selector);
//			conview.setBackgroundDrawable(null);
			service_type.setTextColor(Color.parseColor("#787878"));
		}
		return conview;
	}

	public List<CityArea> getServiceData() {
		return cityAreaList;
	}

	public void setServiceData(List<CityArea> serviceData) {
		this.cityAreaList = serviceData;
	}

}
